<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改排班申请')" />
    <th:block th:include="include :: bootstrap-fileinput-css"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-application-edit" th:object="${tmdDutyApplication}">
        <input name="id" th:value="*{id}" type="hidden">
        <div class="form-group">
            <label class="col-sm-3 control-label">编号：</label>
            <div class="col-sm-8">
                <input name="id" th:value="*{id}" class="form-control" type="text" disabled>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">排班名称：</label>
            <div class="col-sm-8">
                <input name="arrangeName" th:value="*{arrangeName}" class="form-control" type="text" disabled>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">创建人：</label>
            <div class="col-sm-8">
                <input name="createPerson" th:value="*{createPerson}" class="form-control" type="text" disabled>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">创建时间：</label>
            <div class="col-sm-8">
                <input name="createTime" th:value="*{#dates.format(createTime, 'yyyy-MM-dd HH:mm:ss')}" class="form-control" type="text" disabled>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">紧急程度：</label>
            <div class="col-sm-8">
                <input th:value="*{@dict.getLabel('tmd_duty_level', level)}" class="form-control" type="text" disabled>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">部门：</label>
            <div class="col-sm-8">
                <input name="level" th:value="*{deptName}" class="form-control" type="text" disabled>
            </div>
        </div>
        <table style="margin: 0 auto">
            <tr th:each="item,info:${tmdDutyDatePeopleList}" th:object="${item}">
                <td>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">日期：</label>
                        <div class="col-sm-8">
                            <div class="input-group date" >
                                <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                                <input name="dutyDate" th:value="*{#dates.format(dutyDate, 'yyyy-MM-dd HH:mm:ss')}" class="form-control" type="text" disabled>
                            </div>
                        </div>
                    </div>
                </td>
                <td >
                    <div class="form-group"  style="width: 326px">
                        <label class="col-sm-3 control-label"  style="width: 82px">值班人：</label>
                        <div class="col-sm-8">
                            <input name="dutyPersonId" th:value="*{userName}" class="form-control" type="text" disabled>
                        </div>
                    </div>
                </td>
            </tr>
        </table>
        <div class="form-group">
            <label class="col-sm-3 control-label">备注：</label>
            <div class="col-sm-8">
                <textarea name="notes" class="form-control" disabled>[[*{notes}]]</textarea>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">附件：</label>
            <div class="col-sm-8">
                <input type="hidden" name="file" th:value="*{file}">
                <div class="file-loading">
                    <input class="form-control file-upload" id="file" name="file" type="file" disabled>
                </div>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: bootstrap-fileinput-js"/>
<script th:inline="javascript">
    var prefix = ctx + "system/application";
    $("#form-application-edit").validate({
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/edit", $('#form-application-edit').serialize());
        }
    }

    $(".file-upload").each(function (i) {
        var val = $("input[name='" + this.id + "']").val()
        $(this).fileinput({
            'uploadUrl': ctx + 'common/upload',
            initialPreviewAsData: true,
            initialPreview: [val],
            maxFileCount: 1,
            autoReplace: true
        }).on('fileuploaded', function (event, data, previewId, index) {
            $("input[name='" + event.currentTarget.id + "']").val(data.response.url)
        }).on('fileremoved', function (event, id, index) {
            $("input[name='" + event.currentTarget.id + "']").val('')
        })
        $(this).fileinput('_initFileActions');
    });
</script>
</body>
</html>